

package com.example.fw;

import org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.operators.JFrameOperator;

public class ApplicationManager {

        protected FolderHelper folderHelper;
        protected JFrameOperator mainFrame;
        protected MenuHelper menuHelper;

        public ApplicationManager() {
        }

        public void stop() {
                getApplication().requestClose();
        }

        public FolderHelper getFolderHelper() {
                if (folderHelper == null) {
                        folderHelper = new FolderHelper(this);
                }
                return folderHelper;
        }

        public MenuHelper getMenuHelper() {
                if (menuHelper == null) {
                        menuHelper = new MenuHelper(this);
                }
                return menuHelper;
        }

        public JFrameOperator getApplication() {
                if (mainFrame == null) {
                        try {
                                new ClassReference("addressbook.AddressBookFrame").startApplication();
                                mainFrame = new JFrameOperator("jAddressBook");
                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                }
                return mainFrame;
        }

}
